<template>
  <div>
  	<v-Header :item="headerMess"></v-Header>	
  	<v-Content>
  		<div class="box" >
  			<li><span>{{data.equityName}}</span><span style="color: #56627C; font-size: 0.32rem; margin-left: 0.24rem;">{{data.equityCode}}</span></li>
  			<p style="height: 1.1rem; padding-top: .2rem;"><span>点买金额</span><span class="red">{{data.tradeCredit}}万</span></p>
  			<p><span>点买数量</span><span>{{data.dealNumber}}</span></p>
  			<p><span>买入价格</span><span class="red">{{data.buyDealPrice}}</span></p>
  			<p><span>买入时间</span><span>{{data.buyDealTime}}</span></p>
  			<p><span>卖出价格</span><span class="red">--</span></p><!--{{data.sellDealPrice | toPrice}}-->
  			<p><span>卖出时间</span><span>--</span></p><!--{{data.sellDealTime | toPrice}}-->
  			<p><span>备注</span><span>{{data.pingcangType | codeTo2}}</span></p>
  			<li style="color: #babbbc;margin-top: 0.2667rem;"><span>交易综合费</span></li>
  			<p style="height: 1.1rem; padding-top: .2rem;"><span >管理费</span><span class="green">{{data.paidFee}}</span></p>
  			<p><span >延递次数</span><span class="red">{{data.diyanTime}}</span></p>
  			<p><span>延递费用</span><span >{{data.paidDiyan}}</span></p>
  			<li style="color: #babbbc;margin-top: 0.2667rem;;"><span>履约保证金</span></li>
  			<p style="height: 1.1rem; padding-top: .2rem;"><span>冻结</span><span  class="green">{{data.deposit}}</span></p>
  			<p><span >扣减</span><span class="green">0</span></p>
  			<p><span >解冻</span><span class="red">0</span></p>
  			<li style="color: #babbbc;margin-top:0.2667rem;"><span>交易盈亏分配</span></li>
  			<p class="method" style="height: 1.1rem; padding-top: .2rem;margin-bottom: 0.2667rem;"><span>方案状态</span><span class="red">{{data.status | toBoT3}}</span></p>
  		</div>
  	</v-Content>
  	<div class="footer"  @click="make">
  			<p>平仓</p>
  	</div>
  </div>
</template>
<script>
	import Header from '@/components/Header'
	import Content from '@/components/ContentCenter'
	import deal from '@/api/deal/index'
	import { toast} from '@/util/index'
	import { MessageBox} from 'mint-ui'
	export default {
		data(){
			return {
				headerMess:{
	        src:require("../../assets/nav_back.png"),
	        headerText: '点卖明细',
	        right: ''
	    	},
	    	data:""
			}
		},
		methods:{
			make(){
					MessageBox({
					  title: '',
					  message: '<p>确认平仓</p>',
					  showConfirmButton:true,
					  confirmButtonText:"确认",
					  showCancelButton:true,
					  cancelButtonText:"取消"
					}).then(()=> {
				  	this.tosell();
					});
			},
			tosell(){
			 	let senddata = {
					id:this.$route.query.id,
					userId:window.localStorage.getItem("token"),
					plat:"mlj"
				}
				deal.toSell(senddata).then(res=>{
			        if(res.data.code==200){
			        		toast("已平仓");
			        } else if(res.data.code==222){
			            this.$router.push({path:'/login'})
			        }else if(res.data.code==400){
			            toast(res.data.message);
			        }else{
			        	 console.log(res);
			        }
			  })
	  		
			 	
			}
			
			
		},
		components:{
			"v-Header":Header,
			'v-Content': Content
		},
		mounted(){
	  		let senddata = {
				id:this.$route.query.id,
				userId:window.localStorage.getItem("token"),
				plat:"mlj"
			}
			deal.selldetail(senddata).then(res=>{
		        if(res.data.code==200){
		           	this.data=res.data.data;
		        } else if(res.data.code==222){
		            this.$router.push({path:'/login'})
		        }else{
		        	 console.log(res);
		        }
		  	})
  		},
  		filters:{
  			toPrice(value){
  				if(value){
  						return value
  				}else{
  					  return "--"
  				}
  			},
		    codeTo2(value){
		    	if (value=="1") {
		    		return "手动平仓"
		    	}else if(value=="2"){
		    		return "止损平仓"
		    	}else if(value=="3"){
		    		return "递延费不足平仓"
		    	}else if(value=="4"){
		    		return "强制平仓"
		    	}else if(value=="5"){
		    		return "触发递延条件平仓"
		    	} else{
		    		return "无"
		    	}
		     
		    },
		    toBoT3(value){
			  	if(value=="1"){
			    		return "匹配中"
			    	} else if(value=="2"){
			    		return "交易中"
			    	} else if(value=="3"){
			    		return "持仓中"
			    	}else if(value=="4"){
			    		return "待平仓"
			    	} else if(value=="5"){
			    		return "平仓中"
			    	} else if(value=="6"){
			    		return "待结算"
			    	}  else if(value=="7"){
			    		return "已结算"
			    	} else if(value=="8"){
			    		return "流单"
			    	}  
			  }
		  },
		  
	  beforeRouteEnter(to,from,next){
	    document.querySelector('title').innerText='谋略家'
	      next()
	  }
	}
</script>

<style lang="less" scoped>
@import '../../less/config.less';
.box{
	color: white;
	background: @bgColor;
	li{
		list-style: none;
		font-size: @f32;
		height: 1.173rem;
	 	display: flex;
		justify-content:flex-start;
		align-items: center;
		border-bottom: #262934 solid 1px;
		background: #141723;
    padding: 0 0.4rem;
	}
	p{
		display: flex;
		justify-content: space-between;
		align-items: center;
		font-size: @f28;
		color: #babbbc;
		height: 0.88rem;
		background: #141723;
    padding: 0 0.4rem;
	}
	.method{
		height: 1.04rem;
		line-height: 1.04rem;
	}
	.green{
		color: #33ffc3;
	}
	.red{
		color: #FF335B;
	}
}
.footer{
	position: absolute;
	bottom: 0;
	width: 100%;
	background: #FFDD25;
	height: 1.30667rem;
	display: flex;
	justify-content:space-around;
	align-items: center;
	color: #8D4006;
	font-size: 0.48rem;
	span{
		color: #ff335b;
	}
}

</style>
